Skip to content

feat: user online only if not idle#176

Merged
hmbanan666 merged 2 commits into
mainfrom
update-online
Sep 22, 2025
Merged

feat: user online only if not idle#176
hmbanan666 merged 2 commits into
mainfrom
update-online

Conversation

@hmbanan666
Copy link
Copy Markdown
Collaborator

@hmbanan666 hmbanan666 commented Sep 22, 2025

Summary by CodeRabbit

  • New Features

    • Added idle detection (30s) to improve presence tracking across apps.
    • Exposed idle state in user store to enable inactivity-aware behavior.
  • Bug Fixes

    • Online status updates now abort when user is inactive or missing, reducing false “online” indicators.

@hmbanan666 hmbanan666 self-assigned this Sep 22, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 22, 2025

Walkthrough

Added a 30s idle timer via useIdle(30*1000) in two user store files and changed updateOnline to return early if the user id is missing or the idle flag is true (only send online update when id exists and user is NOT idle).

Changes

Cohort / File(s) Summary
User store idle gating (Telegram)
apps/atrium-telegram/app/stores/user.ts
Added useIdle(30 * 1000) and exposed idle; updateOnline now returns early if !id.value OR idle.value is true (only posts online when id exists and user is not idle).
User store idle gating (Web App)
apps/web-app/app/stores/user.ts
Added useIdle(30 * 1000) and exposed idle; updateOnline now returns early if !id.value OR idle.value is true (only posts online when id exists and user is not idle).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UserStore as UserStore
  participant IdleHook as useIdle(30s)
  participant OnlineSvc as Online Update API

  User ->> UserStore: call updateOnline()
  UserStore ->> IdleHook: read idle.value
  alt id.value present AND idle.value == false
    UserStore ->> OnlineSvc: POST /online
    OnlineSvc -->> UserStore: 200 OK
  else missing id OR idle.value == true
    UserStore -->> User: return early (no request)
  end

  note over IdleHook: Idle state from 30s timer (true when idle)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my whiskers, count thirty small ticks,
If an ID blinks and I'm not in nix,
I nudge the net with a gentle thump—
Otherwise I rest, a soft little plump. 🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "feat: user online only if not idle" is a concise, single-line summary that accurately captures the primary change shown in the diffs — adding an idle timer and gating the user's online status on not being idle. It clearly reflects the main behavior modification (useIdle added and updateOnline guard updated) and is suitable for teammates scanning history.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-online

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between def7279 and db15772.

📒 Files selected for processing (2)
  • apps/atrium-telegram/app/stores/user.ts (2 hunks)
  • apps/web-app/app/stores/user.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/web-app/app/stores/user.ts
  • apps/atrium-telegram/app/stores/user.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2477261 and def7279.

📒 Files selected for processing (2)
  • apps/atrium-telegram/app/stores/user.ts (2 hunks)
  • apps/web-app/app/stores/user.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (2)
apps/atrium-telegram/app/stores/user.ts (1)

23-24: Confirm VueUse auto-import for this app or add explicit import; optional alias

Search shows '@vueuse/nuxt' only in packages/ui/nuxt.config.ts (not in apps/atrium-telegram), so auto-import may not be enabled for this app — add an explicit import in apps/atrium-telegram/app/stores/user.ts or enable '@vueuse/nuxt' for the app.

Suggested change:

+import { useIdle } from '@vueuse/core'
-  const { idle } = useIdle(30 * 1000) // 30 sec
+  const { idle: isIdle } = useIdle(30 * 1000) // 30s

Use isIdle.value in guards.

apps/web-app/app/stores/user.ts (1)

27-28: Ensure useIdle is resolvable; optionally alias to isIdle.

  • I found '@vueuse/nuxt' in packages/ui/nuxt.config.ts only — confirm apps/web-app actually inherits/uses that module; if it doesn't, add an explicit import in apps/web-app/app/stores/user.ts (line ~27).
  • Optional readability change: alias idleisIdle and keep the same guard semantics.

Suggested diffs:

+import { useIdle } from '@vueuse/core'
-  const { idle } = useIdle(30 * 1000) // 30 sec
+  const { idle: isIdle } = useIdle(30 * 1000) // 30s

If aliasing, update the guard (preserve original logic):

-      if (!id.value || !idle.value) {
+      if (!id.value || !isIdle.value) {
         return
       }

Comment thread apps/atrium-telegram/app/stores/user.ts Outdated
Comment thread apps/web-app/app/stores/user.ts Outdated
@sonarqubecloud
Copy link
Copy Markdown

@hmbanan666 hmbanan666 merged commit 42ed5b4 into main Sep 22, 2025
8 checks passed
@hmbanan666 hmbanan666 deleted the update-online branch September 22, 2025 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant